Random = Mock.Random

function getKinds(){
    let data = []

    for(let i = 0; i < 8; i++){
        data.push(
            Mock.mock({
            "id" : Random.integer(0,1000),
            "type" : Random.cname(),
            "image" : Random.image()})
        )
    }

    let json = {
        "data" : data,
        "code" : 200,
    }

    return json

}

function getKind(){
    let data = Mock.mock({
        'id' : Random.integer(0,1000),
        'type' : Random.cname(),
        'image' : Random.image()
    })

    let json = {
        data,
        code : 200,
        msg : '获取成功'
    }

    return json
}

function changeKind(){

    let json = {
        code : 200,
        msg : '修改成功'
    }

    return json

}

function add(){

    let json = {
        code : 200,
        msg : '添加成功'
    }

    return json

}


function uploadRes(){
    let json = Mock.mock({
        code : 200,
        data : Random.image(),
        msg: '上传成功'
    })

    return json
}

Mock.mock('http://localhost/pet_kinds.php', 'get', getKinds())

Mock.mock(/http:\/\/localhost\/get_kind.php.*?/, 'get', getKind())

Mock.mock('http://localhost/change_kind_image.php', 'post', changeKind)

Mock.mock('http://localhost/change_kind_info.php', 'post', changeKind)

Mock.mock('http://localhost/upload.php', 'post', uploadRes)

Mock.mock('http://localhost/del_kind.php', 'post', changeKind)

Mock.mock('http://localhost/add_kind.php', 'post', add)
